package com.jzr.bedside.controller.api;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jzr.bedside.db1.model.TInspectResult;
import com.jzr.bedside.db1.service.TInspectResultService;
import com.jzr.common.entity.vo.Result;
import com.jzr.common.util.U;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api("检验结果接口")
@RestController
@RequestMapping("/api/inspectResult")
public class InspectResultController {
    @Autowired
    private TInspectResultService inspectResultService;

    @ApiOperation("获取检验结果列表")
    @GetMapping("/get")
    public Result<List<TInspectResult>> get(@ApiParam("检验结果查询参数") TInspectResult record){
        if(record == null){
            return Result.fail("参数不能为空");
        }
        if(U.isBlank(record.getDocNo())){
            return Result.fail("docNo不能为空");
        }
        QueryWrapper<TInspectResult> qw = new QueryWrapper<>();
        qw.orderByAsc("item_code");
        qw.eq(TInspectResult.DocNo_,record.getDocNo());
        List<TInspectResult> list = inspectResultService.list(qw);
        return Result.success("成功",list,list==null ? 0:list.size());
    }

}
